package com.jsgt.greekfire.ui.dialog

import android.app.Dialog
import android.os.Bundle
import android.view.View
import android.widget.TextView
import com.jsgt.greekfire.R
import com.jsgt.greekfire.base.BaseBottomDialogFragment
import org.jetbrains.anko.find

class AddressClickDialog: BaseBottomDialogFragment() {
    lateinit var copyListener: () -> Unit
    lateinit var editListener: () -> Unit

    fun copyListener(copyListener: () -> Unit): AddressClickDialog {
        this.copyListener = copyListener
        return this
    }

    fun editListener(editListener: () -> Unit): AddressClickDialog {
        this.editListener = editListener
        return this
    }

    override fun getLayoutId(): Int {
        return R.layout.dialog_adress_click
    }

    override fun canCancel(): Boolean {
        return true
    }

    override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
        val dialog = super.onCreateDialog(savedInstanceState)
        dialog.find<View>(R.id.txvCancel).setOnClickListener {
            dismiss()
        }
        dialog.find<TextView>(R.id.txvCopy).setOnClickListener {
            copyListener.invoke()
            dismiss()
        }
        dialog.find<TextView>(R.id.txvEdit).setOnClickListener {
            editListener.invoke()
            dismiss()
        }
        return dialog
    }
}